package io.jee.runshan.controller.admin;

import io.jee.medusa.orm.condition.Condition;
import io.jee.medusa.orm.condition.ConditionGroup;
import io.jee.medusa.orm.pager.Pager;
import io.jee.runshan.domain.VIP;
import io.jee.runshan.service.IVIPService;
import io.jee.runshan.utils.StringUtils;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 会员管理
 * 
 * @Created: 2015年1月24日
 * @Last_modified: 2015年1月24日 下午11:46:17
 * @Last_modified_by: ynshun
 * @Create_by: ynshun
 *
 */
@Controller
@RequestMapping("/admin/vip/")
public class VIPController {
	@Resource
	private IVIPService vipService;
	
	@RequestMapping("list")
	public void list(Pager<VIP> pager, Model model, String key) {
		ConditionGroup group = new ConditionGroup();
		group.and(Condition.onText("VIPCardNo").notNull());
		if (StringUtils.notBlank(key)) {
			group.and(Condition.onText("name").like(key + "%"));
			group.or(Condition.onText("VIPCardNo").eq(key));
			group.or(Condition.onText("mobile").eq(key));
			group.or(Condition.onText("IDCardNo").eq(key));
		}
		pager = vipService.list(pager, group);
		model.addAttribute("key", key);
	}
}
